<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>霸王餐小程序后台管理 - 登录</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <!--<link href="css/nifty.css" rel="stylesheet">-->
    <link href="/css/plugins/sweetalert2/sweetalert2.min.css" rel="stylesheet">
    <link href="/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <!--复选框-->
    <link href="/css/plugins/magic-check/css/magic-check.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
</head>

<body class="bg-img" th:style="'background:url(' + @{${bgurl}} + ')'">
<div class="cls-content">
    <div class="cls-content-sm panel">
        <div class="panel-body">
            <div class="mar-ver pad-btm">
                <h3 class="h4 mar-no" th:text="${title}"></h3>
            </div>
            <form role="form" action="/dologin" enctype="multipart/form-data" method="post"
                  onsubmit="return login()">
                <div class="form-group">
                    <input type="text" id="username" name="username" class="form-control" placeholder="用户名" autofocus
                           th:text="${username}">
                </div>
                <div class="form-group">
                    <input type="password" id="password" name="password" class="form-control" placeholder="密码">
                </div>
                <div class="checkbox pad-btm text-left">
                    <input type="text" id="captcha" name="captcha" class="form-control" placeholder="请输入右侧计算结果"
                           style="float: left;width: 162px;margin-right: 40px;">
                    <img id="codeImg" alt="验证码出错啦~!" onclick="refreshcode()" style="display: inline-block;height: 34px;" src="/validcode">
                </div>
                <!--<div class="checkbox pad-btm text-left">-->
                <!--<input id="demo-form-checkbox" class="magic-checkbox" type="checkbox" checked="checked" id="rememberMe" name="rememberMe">-->
                <!--<label for="demo-form-checkbox">记住我</label>-->
                <!--</div>-->
                <button type="submit" id="btnlogin" class="btn btn-primary block full-width m-b"
                        style="margin-top: 20px">登 录
                </button>
            </form>
        </div>
        <div class="pad-all">
            <!--<a href="#forget" class="btn-link mar-rgt">忘记密码 ?</a>-->
            <!--<a href="#register" class="btn-link mar-lft">注册新账号</a>-->
            <div class="media pad-top bord-top">
                <div class="pull-right">
                    <a href="#" class="pad-rgt"><i class="ti-facebook icon-lg text-primary"></i></a>
                    <a href="#" class="pad-rgt"><i class="ti-twitter-alt icon-lg text-info"></i></a>
                    <a href="#" class="pad-rgt"><i class="ti-google icon-lg text-danger"></i></a>
                </div>
                <!--<div class="media-body text-left">其他方式登陆</div>-->
            </div>
        </div>
    </div>
</div>
<script src="/js/jquery.min-2.1.4.js"></script>
<script src="/js/plugins/sweetalert2/sweetalert2.js"></script>
<!-- IE support -->
<script src="/js/plugins/es6-promise.min.js"></script>
<!-- Promise.finally support -->
<script src="/js/plugins/finally.js"></script>
<!--<script src="js/bootstrap.min.js?v=3.3.6"></script>-->
</body>
<script th:inline="javascript">

    var msg = [[${msg}]];
    if (msg != null && msg.length > 0) swal("提示", msg, "error")
    function refreshcode() {
        var img=document.getElementById("codeImg");
        img.src="/validcode?ts="+new Date().getTime();
    }
    function login() {
        console.log("start to login")
        var url = "/ajaxLogin";
        var username = $("#username").val().replace(/\s+/g, "");
        var password = $("#password").val().replace(/\s+/g, "");
        var captcha = $("#captcha").val().replace(/\s+/g, "");
        var rememberMe = $("#rememberMe").val();

        if (username == "") {
            swal("提示", "请输入用户名", "warning")
            return false
        }
        if (password == "") {
            swal("提示", "请输入登陆密码", "warning")
            return false
        }
        if (captcha == "") {
            swal("提示", "请输入验证码", "warning")
            return false
        }
        return true;
//        $.post(url,{username:username,password:password,captcha:captcha,rememberMe:rememberMe=="on"?true:false},function(e){
//            console.log("---------------------------------login ck")
//            console.log(e)
//            if(e.code==0){
//                console.log(e)
//                window.location.href = "/home"
//            }else{
//                swal("提示",e.msg,"error")
//            }
//        },"json");
    }

    //    $(document).ready(function(){
    //        $("#btnlogin").click(function(){
    //            login()
    //        });
    //    });

</script>
</html>
